//
//  DeblockingTableViewCell.m
//  EPBPro
//
//  Created by wucha on 2018/8/3.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "DeblockingTableViewCell.h"
@interface DeblockingTableViewCell(){
    DeBlockingBlock deBlock;
}
@property (nonatomic,strong) UILabel *timeLabel;

@end

@implementation DeblockingTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        UILabel *timeLabel = [UILabel new];
        timeLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:timeLabel];
        self.timeLabel = timeLabel;
        timeLabel.sd_layout.leftSpaceToView(self.contentView, 10).topSpaceToView(self.contentView, 0).widthIs(SCREEN_WIDTH-100).bottomSpaceToView(self.contentView, 0);
        
        UIButton *cancelButton = [UIButton new];
        cancelButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [cancelButton setTitleColor:DefaultBlueColor forState:UIControlStateNormal];
        [cancelButton setTitle:@"取消解锁" forState:UIControlStateNormal];
        [cancelButton addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:cancelButton];
        cancelButton.sd_layout.rightSpaceToView(self.contentView, 10).topSpaceToView(self.contentView, 0).widthIs(100).bottomSpaceToView(self.contentView, 0);
        
        UIView *lineView = [UIView new];
        lineView.backgroundColor = DefaultCellLineColor;
        [self.contentView addSubview:lineView];
        lineView.sd_layout.leftSpaceToView(self.contentView, 0).bottomSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 0).heightIs(1);
    }
    return self;
}

-(void)setDeblockingCell:(TransHistory*)transHistory withBlock:(DeBlockingBlock)deBlockingBlock{
    _timeLabel.text = [NSString stringWithFormat:@"%@            %@",transHistory.createTime,transHistory.amount];
    deBlock = deBlockingBlock;
}

-(void)cancelAction:(id)sender{
    if(deBlock){
        deBlock();
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
